﻿//************************************************************************************************
// Copyright © 2014 Steven M. Cohn. All Rights Reserved.
// 
//************************************************************************************************

namespace River.Folderize.UI
{
	using System;
	using System.Windows;
	using System.Windows.Controls;
	using System.Windows.Controls.Primitives;
	using System.Windows.Media.Imaging;


	public class ImageToggle : ToggleButton
	{
		static ImageToggle ()
		{
			DefaultStyleKeyProperty.OverrideMetadata(
				typeof(ImageToggle),
				new FrameworkPropertyMetadata(typeof(ImageToggle)));
		}


		public static readonly DependencyProperty BorderVisibilityProperty =
			DependencyProperty.Register("BorderVisibility", typeof(Visibility), typeof(ImageToggle),
			new FrameworkPropertyMetadata(Visibility.Hidden, FrameworkPropertyMetadataOptions.AffectsRender));


		public static readonly DependencyProperty CheckedImageProperty =
			DependencyProperty.Register("CheckedImage", typeof(BitmapImage), typeof(ImageToggle));


		public static readonly DependencyProperty CheckedDisabledImageProperty =
			DependencyProperty.Register("CheckedDisabledImage", typeof(BitmapImage), typeof(ImageToggle));


		public static readonly DependencyProperty CheckedHoverImageProperty =
			DependencyProperty.Register("CheckedHoverImage", typeof(BitmapImage), typeof(ImageToggle));


		public static readonly DependencyProperty ImageSizeProperty =
			DependencyProperty.Register("ImageSize", typeof(double), typeof(ImageToggle));


		public static readonly DependencyProperty UncheckedImageProperty =
			DependencyProperty.Register("UncheckedImage", typeof(BitmapImage), typeof(ImageToggle));


		public static readonly DependencyProperty UncheckedHoverImageProperty =
			DependencyProperty.Register("UncheckedHoverImage", typeof(BitmapImage), typeof(ImageToggle));


		public static readonly DependencyProperty UncheckedDisabledImageProperty =
			DependencyProperty.Register("UncheckedDisabledImage", typeof(BitmapImage), typeof(ImageToggle));
			//new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender, ImageSourceChanged));


		public Visibility BorderVisibility
		{
			get { return (Visibility)GetValue(BorderVisibilityProperty); }
			set { SetValue(BorderVisibilityProperty, value); }
		}

	
		public BitmapImage CheckedImage
		{
			get { return (BitmapImage)GetValue(CheckedImageProperty); }
			set { SetValue(CheckedImageProperty, value); }
		}


		public BitmapImage CheckedDisabledImage
		{
			get { return (BitmapImage)GetValue(CheckedDisabledImageProperty); }
			set { SetValue(CheckedDisabledImageProperty, value); }
		}


		public BitmapImage CheckedHoverImage
		{
			get { return (BitmapImage)GetValue(CheckedHoverImageProperty); }
			set { SetValue(CheckedHoverImageProperty, value); }
		}


		public BitmapImage UncheckedImage
		{
			get { return (BitmapImage)GetValue(UncheckedImageProperty); }
			set { SetValue(UncheckedImageProperty, value); }
		}


		public BitmapImage UncheckedDisabledImage
		{
			get { return (BitmapImage)GetValue(UncheckedDisabledImageProperty); }
			set { SetValue(UncheckedDisabledImageProperty, value); }
		}


		public BitmapImage UncheckedHoverImage
		{
			get { return (BitmapImage)GetValue(UncheckedHoverImageProperty); }
			set { SetValue(UncheckedHoverImageProperty, value); }
		}


		public double ImageSize
		{
			get { return (double)GetValue(ImageSizeProperty); }
			set { SetValue(ImageSizeProperty, value); }
		}


		private static void ImageSourceChanged (
			DependencyObject sender, DependencyPropertyChangedEventArgs e)
		{
			Application.GetResourceStream(new Uri("pack://application:,,," + (string)e.NewValue));
		}
	}
}